package com.struts.form;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class FullForm {

	public static Form full(HttpServletRequest request,String formPath){
		
		Form form = null;
		
		try {
			
			Class clazz = Class.forName(formPath);
			form = (Form) clazz.newInstance();
			
			Field[] fields = clazz.getDeclaredFields();
			
			for(Field field : fields){
				
				field.setAccessible(true);
				field.set(form, request.getParameter(field.getName()));
				field.setAccessible(false);
			}
			
		} catch (Exception e) {

			System.out.println("错误：bean 装载失败！");
			e.printStackTrace();
			
		}
		
		return form;
	}
}
